package com.yellowpage.bigdata.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.bigdata.data.TmApponoffSilentUserDay;
import com.yellowpage.bigdata.dao.TmApponoffSilentUserDayDao;

public class TmApponoffSilentUserDayServiceImpl extends BaseServiceImpl implements TmApponoffSilentUserDayService {
	private TmApponoffSilentUserDayDao tmApponoffSilentUserDayDao;

	public void setTmApponoffSilentUserDayDao(TmApponoffSilentUserDayDao tmApponoffSilentUserDayDao) {
		this.tmApponoffSilentUserDayDao = tmApponoffSilentUserDayDao;
	}

	/* Smooth generate Method */
	public TmApponoffSilentUserDay getTmApponoffSilentUserDay(Long id) {
		return tmApponoffSilentUserDayDao.get(id);
	}

	public List<TmApponoffSilentUserDay> getAllTmApponoffSilentUserDay() {
		return tmApponoffSilentUserDayDao.getAll();
	}

	public List<Map> queryTmApponoffSilentUserDayByPage(Map queryMap, PageRender pageRender) {

		QueryAssistantSQL sqlAssistant = baseDao
				.newQueryAssistantSQL(
						"SELECT a.VERSION , a.NEW_USER_CNTS , a.SILENT_USER_CNTS , a.CHANNEL_NO ,(select b.NAME from OMC_DIC_TABLE b where b.VALUE = a.CHANNEL_NO and b.DIC_NAME='NSP_ONOFFLOG_CHANNEL_NO') as CHANNEL_NO_NAME, (a.RATE*100) RATE ,a.DAY_ID , a.DEAL_DATE     FROM TM_APPONOFF_SILENT_USER_DAY a WHERE 1=1 AND  IS_VALIDE ='1' ")
				.addCondition(" and VERSION = :version ")
				.addCondition(" and CHANNEL_NO = :channelNo ")
				.addCondition(" and DAY_ID >= :dayIdStart ")
				.addCondition(" and DAY_ID <= :dayIdEnd ");

		List<Map> resultList = sqlAssistant.queryByPage(baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}

	public void saveTmApponoffSilentUserDay(TmApponoffSilentUserDay tmApponoffSilentUserDay) {
		tmApponoffSilentUserDayDao.save(tmApponoffSilentUserDay);
	}

	public void updateTmApponoffSilentUserDay(TmApponoffSilentUserDay tmApponoffSilentUserDay) {
		tmApponoffSilentUserDayDao.update(tmApponoffSilentUserDay);
	}

	public void delete(List deleteList) {
		tmApponoffSilentUserDayDao.remove(deleteList);
	}

}